<?
include('seguridad.php');
include('bd.php');
Conectar();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> BideYoday </TITLE>
  <META NAME="Generator" CONTENT="DILAPER">
  <META NAME="Author" CONTENT="Power by Sebastian Costa - Design: Nadia De Cinti">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <link href="../style.css" rel="stylesheet" type="text/css">
  <script src="../js/botonera.js" type="text/javascript"></script>
    <script language="JavaScript" type="text/JavaScript">

function validar_coment(form)
{
	if(form.name.value == '') {
		alert("Please insert Name");
		form.name.focus();
		return false;
	}
	if(form.modle.value == '') {
		alert("Please insert modle");
		form.modle.focus();
		return false;
	}
	if(form.price_d.value == '') {
		alert("Please insert price");
		form.price_d.focus();
		return false;
	}
		
	document.getElementById('product_edit').submit();
}
</script>
 </HEAD>

 <BODY topmargin="0">
<center>
<table width="990" height="100%" cellspacing="0" cellpadding="0" class="fondo" border="0">
	<tr>
		<td width="100%" height="100%" align="center" valign="top">
			<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
				<tr>
					<td align="center" valign="top">
<div style="height: 135px"></div>
<!-- contenido -->
<table width="800"  border="0" class="admin_area" cellspacing="0" cellpadding="0">
	<tr bgcolor="#ffffff">
		<td align="right" height="30">
Welcome <?echo $_SESSION['usuario'];?>&nbsp;|&nbsp;<a href="salir.php"><font color="red">Log Out</font></a>&nbsp;&nbsp;
		</td>
	</tr>	
	<tr><td height="3"></td></tr>
	<tr bgcolor="#ffffff">
		<td align="right" height="50">
<?include('menu.php');?>
		</td>
	</tr>	
	<tr><td height="3"></td></tr>
	<tr bgcolor="#ffffff">
		<td align="left" valign="top" height="300"  class="tabla_central">
<div style="margin: 10px">
<?
$result=mysql_query("SELECT * FROM products WHERE id='".$_GET[id]."'");
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
?>
<b><span class="titulo_admin">Products:&nbsp;&nbsp;<?echo$row[name]?></b>&nbsp;Modle:&nbsp;<b><?echo$row[modle]?></b>&nbsp;&nbsp;|&nbsp;&nbsp;code: <?echo$row[code]?></span></b><br>
<br>
To edit product<br>
<br>
<form name="product_edit" id="product_edit" method="POST" action="acciones/products_max_save.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?echo$row[id];?>">
<input type="hidden" name="code" value="<?echo$row[code];?>">
<table width="100%" border="0" class="tabla_admin">
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Name&nbsp;&nbsp;</b>
		</td>
		<td>
<input type="text" name="name" value="<?echo$row[name];?>">
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Modle&nbsp;&nbsp;</b>
		</td>
		<td>
<input type="text" name="modle" value="<?echo$row[modle];?>">
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Main Modle&nbsp;&nbsp;</b><br>
	<?if(file_exists('../img_modle/'.$row[code].'.jpg')){?>
<img src="../img_modle/<?echo $row[code]?>.jpg">
	<?}else{echo'<font color="red">WITHOUT PHOTO.</font>';}?>
		</td>
		<td>
<input type="file" name="img_modle">
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Main Image&nbsp;&nbsp;</b><br>
	<?if(file_exists('../img_products/'.$row[code].'-1.jpg')){?>
<img src="../img_products/<?echo $row[code]?>-1.jpg">
	<?}else{echo'<font color="red">WITHOUT PHOTO,<br>I DO NOT KNOW IT PUBLISHES</font>';}?>
		</td>
		<td>
<input type="file" name="principal">
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Type Products&nbsp;&nbsp;</b>
		</td>
		<td>
<?if($row[type]=='principal'){$a='checked'; $b='';}else if($row[type]=='accessory'){$b='checked';$a='';}?>
Principal&nbsp;<input type="radio" name="type" value="principal" <?echo$a?>>&nbsp;&nbsp;Accessory&nbsp;<input type="radio" name="type" value="accessory" <?echo$b?>>
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Shape&nbsp;&nbsp;</b>
		</td>
		<td>
<?
$result_s=mysql_query("SELECT * FROM shape ORDER BY shape DESC");
$q_s='1';
$w_s='1';
$cadena_s=$row[shape];
while($row_s = mysql_fetch_array($result_s, MYSQL_ASSOC)){
$palabra_s=preg_quote($row_s[shape]); 
if(eregi("[ b\t\n\r]+".$palabra_s."[ b\t\n\r]+",$cadena_s)){
	$checked.$q_s='checked';
}else{
    $checked.$q_s='';
}  

?><input type="checkbox" name="shape[<?echo $w_s;?>]" value="<?echo$row_s[shape];?>" <?echo$checked.$q_s?>>&nbsp;<?echo$row_s[shape]?><br><?	
$q_s++;$w_s++;}?>
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Color&nbsp;&nbsp;</b>
		</td>
		<td>
<?
$result_c=mysql_query("SELECT * FROM color ORDER BY color DESC");
$q='1';
$w='1';
$cadena=$row[color];
while($row_c = mysql_fetch_array($result_c, MYSQL_ASSOC)){
$palabra=preg_quote($row_c[color]); 
if(eregi("[ a\t\n\r]+".$palabra."[ a\t\n\r]+",$cadena)){
	$checked.$q='checked';
}else{
    $checked.$q='';
}  

?><input type="checkbox" name="color[<?echo $w;?>]" value="<?echo$row_c[color];?>" <?echo$checked.$q?>>&nbsp;<?echo$row_c[color]?><br><?	
$q++;$w++;}?>
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Price&nbsp;&nbsp;</b>
		</td>
		<td>
<?
$price_d= substr($row[price], 0, strlen($row[price]) -2);
$price_c= substr($row[price], -2, 2);
?>
$<input type="text" name="price_d" size="2" value="<?echo$price_d;?>">,<input type="text" name="price_c" value="00" size="2" value="<?echo$price_c;?>">
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Box Weight&nbsp;&nbsp;</b>
		</td>
		<td>
<input type="text" name="peso" value="<?echo$row[peso];?>" size="2"> lb
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Width&nbsp;&nbsp;</b>
		</td>
		<td>
<input type="text" name="width" value="<?echo$row[width];?>" size="2"> in
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Height&nbsp;&nbsp;</b>
		</td>
		<td>
<input type="text" name="height" value="<?echo$row[height];?>" size="2"> in
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Length&nbsp;&nbsp;</b>
		</td>
		<td>
<input type="text" name="lenght" value="<?echo$row[lenght];?>" size="2"> in
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Related Products&nbsp;&nbsp;</b>
		</td>
		<td>
<?
$result_r=mysql_query("SELECT code, name, modle FROM products ORDER BY name DESC");
$e='0';
$w_r='0';
$cadena_r=$row[parent];
while($row_r = mysql_fetch_array($result_r, MYSQL_ASSOC)){
$palabra_r=str_replace(' ', '', $row_r[modle]); 
if(eregi("[ x\t\n\r]+".$palabra_r."[ x\t\n\r]+",$cadena_r)){
	$checked.$e='checked';
}else{
    $checked.$e='';
}  
if($row_r[modle]!=$row[modle]){?>
<input type="checkbox" name="parent[<?echo $w_r;?>]"value="<?echo str_replace(' ', '', $row_r[modle]);?>"<?echo$checked.$e?>>&nbsp;<?echo$row_r[modle]?><br><?	
}$e++;$w_r++;}?>
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff" valign="top">
<br>
<b>Overview&nbsp;&nbsp;</b><br>
<br>
	<?if(file_exists('../img_overview/'.$row[code].'.jpg')){?>
<img src="../img_overview/<?echo $row[code]?>.jpg">
	<?}else{echo'<font color="red">WITHOUT PHOTO</font>';}?>
		</td>
		<td>
<br>
&nbsp;&nbsp;Text<br>
<textarea name="overview" rows="10" cols="50"><?echo$row[overview];?></textarea><br>
<br>
&nbsp;&nbsp;Image&nbsp;&nbsp;<input type="file" name="img_overview">&nbsp;&nbsp;
&nbsp;&nbsp;Delete img&nbsp;&nbsp;<input type="checkbox" name="borrar_overview" value="yes"><br>
<br>
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff" valign="top">
<br>
<b>Details&nbsp;&nbsp;</b><br>
<br>
	<?if(file_exists('../img_details/'.$row[code].'.jpg')){?>
<img src="../img_details/<?echo $row[code]?>.jpg">
	<?}else{echo'<font color="red">WITHOUT PHOTO</font>';}?>
		</td>
		<td>
<br>
&nbsp;&nbsp;Text<br>
<textarea name="details" rows="10" cols="50"><?echo$row[details];?></textarea><br>
<br>
&nbsp;&nbsp;Image&nbsp;&nbsp;<input type="file" name="img_details">&nbsp;&nbsp;
&nbsp;&nbsp;Delete img&nbsp;&nbsp;<input type="checkbox" name="borrar_details" value="yes"><br>
<br>
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff" valign="top">
<br>
<b>Installations&nbsp;&nbsp;</b><br>
<br>
	<?if(file_exists('../img_installation/'.$row[code].'.jpg')){?>
<img src="../img_installation/<?echo $row[code]?>.jpg">
	<?}else{echo'<font color="red">WITHOUT PHOTO</font>';}?>
		</td>
		<td>
<br>
&nbsp;&nbsp;Text<br>
<textarea name="installation" rows="10" cols="50"><?echo$row[installation];?></textarea><br>
<br>
&nbsp;&nbsp;Image&nbsp;&nbsp;<input type="file" name="img_installation">&nbsp;&nbsp;
&nbsp;&nbsp;Delete img&nbsp;&nbsp;<input type="checkbox" name="borrar_installation" value="yes"><br>
<br>
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff" valign="top">
<br>
<b>Warranty&nbsp;&nbsp;</b><br>
<br>
	<?if(file_exists('../img_warranty/'.$row[code].'.jpg')){?>
<img src="../img_warranty/<?echo $row[code]?>.jpg">
	<?}else{echo'<font color="red">WITHOUT PHOTO</font>';}?>
		</td>
		<td>
<br>
&nbsp;&nbsp;Text<br>
<textarea name="warranty" rows="10" cols="50"><?echo$row[warranty];?></textarea><br>
<br>
&nbsp;&nbsp;Image&nbsp;&nbsp;<input type="file" name="img_warranty">&nbsp;&nbsp;
&nbsp;&nbsp;Delete img&nbsp;&nbsp;<input type="checkbox" name="borrar_warranty" value="yes"><br>
<br>
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Activate Code Promotion&nbsp;&nbsp;</b>
		</td>
		<td>
<input type="text" name="activacion" value="<?echo$row[activacion];?>">
		</td>
	</tr>
	<tr>
		<td align="right" bgcolor="#ffffff">
<b>Include video&nbsp;&nbsp;</b>
		</td>
		<td>
<?if($row[video]=='yes'){$a_v='checked'; $b_v='';}else if($row[video]=='no' or $row[video]==''){$b_v='checked';$a_v='';}?>
Yes&nbsp;<input type="radio" name="video" value="yes" <?echo$a_v?>>&nbsp;&nbsp;No&nbsp;<input type="radio" name="video" value="no" <?echo$b_v?>>
		</td>
	</tr>
	<tr>
		<td colspan="2" bgcolor="#ffffff" align="center">
<input type="button" value="Save Step 1" onClick="javascript:validar_coment(document.getElementById('product_edit'));">
		</td>
	</tr>
</table>
</form>
<?}?>
</div>
<br>
		</td>
	</tr>
</table>
<table width="800" border="0" class="admin_area" cellspacing="0" cellpadding="0">
	<tr>
		<td height="3">

		</td>
	</tr>
	<tr bgcolor="#ffffff">
		<td align="right">
<?include('inc/foot.php');?>
		</td>
	</tr>
</table>
<!-- fin contenido -->
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</center>
 </BODY>
</HTML>
<?Desconectar();?>